<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 5.4.0">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">

<link rel="stylesheet" href="//fonts.googleapis.com/css?family=Noto Serif SC:300,300italic,400,400italic,700,700italic|Source Code Pro:300,300italic,400,400italic,700,700italic&display=swap&subset=latin,latin-ext">
<link rel="stylesheet" href="/lib/font-awesome/css/all.min.css">

<script id="hexo-configurations">
    var NexT = window.NexT || {};
    var CONFIG = {"hostname":"example.com","root":"/","scheme":"Pisces","version":"7.8.0","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12,"onmobile":false},"copycode":{"enable":true,"show_result":true,"style":"flat"},"back2top":{"enable":true,"sidebar":false,"scrollpercent":true},"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"algolia":{"hits":{"per_page":10},"labels":{"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}},"localsearch":{"enable":false,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}}};
  </script>

  <meta name="description" content="最近公司做一款用户拍照识别垃圾的功能，参考了各大服务提供商的图片识别效果，最终百度胜出。以下是如何手动不通过AFNetworking或者Alamofire的框架，直接手动将百度图片识别功能集成到自己的项目中。">
<meta property="og:type" content="article">
<meta property="og:title" content="百度图片识别iOS实现!">
<meta property="og:url" content="http://example.com/2019/10/06/iOS/%E7%99%BE%E5%BA%A6%E5%9B%BE%E7%89%87%E8%AF%86%E5%88%ABiOS%E5%AE%9E%E7%8E%B0/index.html">
<meta property="og:site_name" content="HR&#39;s Blog">
<meta property="og:description" content="最近公司做一款用户拍照识别垃圾的功能，参考了各大服务提供商的图片识别效果，最终百度胜出。以下是如何手动不通过AFNetworking或者Alamofire的框架，直接手动将百度图片识别功能集成到自己的项目中。">
<meta property="og:locale" content="en_US">
<meta property="article:published_time" content="2019-10-06T11:39:52.000Z">
<meta property="article:modified_time" content="2021-03-18T04:23:18.000Z">
<meta property="article:author" content="HR">
<meta name="twitter:card" content="summary">

<link rel="canonical" href="http://example.com/2019/10/06/iOS/%E7%99%BE%E5%BA%A6%E5%9B%BE%E7%89%87%E8%AF%86%E5%88%ABiOS%E5%AE%9E%E7%8E%B0/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome : false,
    isPost : true,
    lang   : 'en'
  };
</script>

  <title>百度图片识别iOS实现! | HR's Blog</title>
  
    <script async src="https://www.googletagmanager.com/gtag/js?id=UA-61905451-1"></script>
    <script>
      if (CONFIG.hostname === location.hostname) {
        window.dataLayer = window.dataLayer || [];
        function gtag(){dataLayer.push(arguments);}
        gtag('js', new Date());
        gtag('config', 'UA-61905451-1');
      }
    </script>






  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container use-motion">
    <div class="headband"></div>

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="Toggle navigation bar">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <h1 class="site-title">HR's Blog</h1>
      <span class="logo-line-after"><i></i></span>
    </a>
      <p class="site-subtitle" itemprop="description">Swimming 🏊 in the sea🌊of code!</p>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
    </div>
  </div>
</div>




<nav class="site-nav">
  <ul id="menu" class="main-menu menu">
        <li class="menu-item menu-item-home">

    <a href="/" rel="section"><i class="fa fa-home fa-fw"></i>Home</a>

  </li>
        <li class="menu-item menu-item-about">

    <a href="/about/" rel="section"><i class="fa fa-user fa-fw"></i>About</a>

  </li>
        <li class="menu-item menu-item-tags">

    <a href="/tags/" rel="section"><i class="fa fa-tags fa-fw"></i>Tags</a>

  </li>
        <li class="menu-item menu-item-categories">

    <a href="/categories/" rel="section"><i class="fa fa-th fa-fw"></i>Categories</a>

  </li>
        <li class="menu-item menu-item-archives">

    <a href="/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>Archives</a>

  </li>
  </ul>
</nav>




</div>
    </header>

    
  <div class="back-to-top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>
  <div class="reading-progress-bar"></div>


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content post posts-expand">
            

    
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="en">
    <link itemprop="mainEntityOfPage" href="http://example.com/2019/10/06/iOS/%E7%99%BE%E5%BA%A6%E5%9B%BE%E7%89%87%E8%AF%86%E5%88%ABiOS%E5%AE%9E%E7%8E%B0/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="HR">
      <meta itemprop="description" content="Swimming 🏊 in the sea🌊of code!">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="HR's Blog">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          百度图片识别iOS实现!
        </h1>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">Posted on</span>

              <time title="Created: 2019-10-06 19:39:52" itemprop="dateCreated datePublished" datetime="2019-10-06T19:39:52+08:00">2019-10-06</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="far fa-calendar-check"></i>
                </span>
                <span class="post-meta-item-text">Edited on</span>
                <time title="Modified: 2021-03-18 12:23:18" itemprop="dateModified" datetime="2021-03-18T12:23:18+08:00">2021-03-18</time>
              </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-folder"></i>
              </span>
              <span class="post-meta-item-text">In</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/iOS/" itemprop="url" rel="index"><span itemprop="name">iOS</span></a>
                </span>
            </span>

          

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
        <p>最近公司做一款用户拍照识别垃圾的功能，参考了各大服务提供商的图片识别效果，最终百度胜出。以下是如何手动不通过<code>AFNetworking</code>或者<code>Alamofire</code>的框架，直接手动将百度图片识别功能集成到自己的项目中。</p>
<span id="more"></span>


<h2 id="百度图片请求"><a href="#百度图片请求" class="headerlink" title="百度图片请求"></a>百度图片请求</h2><p>百度要求Header参数<code>Content-Type</code>的<code>application/x-www-form-urlencoded</code><br>图像数据，base64编码，要求base64编码后大小不超过4M，最短边至少20px，长宽比3：1之内，最长边最大4096px,支持jpg/png/bmp格式 。注意：图片需要base64编码、去掉编码头后再进行urlencode。</p>
<ul>
<li>在NSString里面换行是<code>\r\n</code>来换行</li>
<li>不同的<code>Content-Type</code>，数据的拼接方式不一样</li>
</ul>
<h2 id="HTTP-body的数据的格式"><a href="#HTTP-body的数据的格式" class="headerlink" title="HTTP body的数据的格式"></a>HTTP body的数据的格式</h2><h3 id="application-x-www-form-urlencoded"><a href="#application-x-www-form-urlencoded" class="headerlink" title="application/x-www-form-urlencoded"></a>application/x-www-form-urlencoded</h3><p>另外一种使用得比较多的数据格式是<code>multipart/form-data</code></p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">Header</span><br><span class="line">Content-Type: application&#x2F;x-www-form-urlencoded; charset&#x3D;utf-8</span><br><span class="line"></span><br><span class="line">Body</span><br><span class="line">image&#x3D;imageValue&amp;anotherKey&#x3D;anotherValues</span><br></pre></td></tr></table></figure>

<h4 id="代码"><a href="#代码" class="headerlink" title="代码"></a>代码</h4><figure class="highlight objectivec"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">NSData</span> *imageData = <span class="built_in">UIImagePNGRepresentation</span>(image);</span><br><span class="line"><span class="built_in">NSString</span> *imageString = [imageData base64EncodedStringWithOptions:<span class="built_in">NSDataBase64Encoding64CharacterLineLength</span>].stringByURLEncode;</span><br><span class="line"><span class="built_in">NSMutableData</span> *body = [<span class="built_in">NSMutableData</span> data];</span><br><span class="line"><span class="built_in">NSData</span> *imageFinalData = [[<span class="built_in">NSString</span> stringWithFormat:<span class="string">@&quot;image=%@&quot;</span>, imageString] dataUsingEncoding:<span class="built_in">NSUTF8StringEncoding</span>];</span><br><span class="line">[body appendData:imageFinalData];</span><br><span class="line"><span class="built_in">NSURLSession</span> *session = [<span class="built_in">NSURLSession</span> sharedSession];</span><br><span class="line"><span class="built_in">NSURL</span> *url = [<span class="built_in">NSURL</span> URLWithString:[<span class="built_in">NSString</span> stringWithFormat:<span class="string">@&quot;https://aip.baidubce.com/rest/2.0/image-classify/v2/advanced_general?access_token=%@&quot;</span>, <span class="keyword">self</span>.token]];</span><br><span class="line"><span class="built_in">NSMutableURLRequest</span> *request = [<span class="built_in">NSMutableURLRequest</span> requestWithURL:url];</span><br><span class="line">request.HTTPMethod = <span class="string">@&quot;POST&quot;</span>;</span><br><span class="line">request.HTTPBody = body;</span><br><span class="line">[request addValue:[<span class="built_in">NSString</span> stringWithFormat:<span class="string">@&quot;application/x-www-form-urlencoded; charset=utf-8&quot;</span>] forHTTPHeaderField:<span class="string">@&quot;Content-Type&quot;</span>];</span><br><span class="line"><span class="built_in">NSURLSessionDataTask</span> *uploadTask = [session dataTaskWithRequest:request completionHandler:^(<span class="built_in">NSData</span> *data, <span class="built_in">NSURLResponse</span> *response, <span class="built_in">NSError</span> *error) &#123;</span><br><span class="line">	<span class="built_in">NSDictionary</span> *result = [<span class="built_in">NSJSONSerialization</span> JSONObjectWithData:data options:kNilOptions error:&amp;error];</span><br><span class="line">    <span class="comment">//百度返回结果</span></span><br><span class="line">&#125;];</span><br><span class="line">[uploadTask resume];</span><br></pre></td></tr></table></figure>

<h4 id="最终格式"><a href="#最终格式" class="headerlink" title="最终格式"></a>最终格式</h4><figure class="highlight objectivec"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">POST /rest/<span class="number">2.0</span>/image-classify/v2/advanced_general HTTP/<span class="number">1.1</span></span><br><span class="line">Host: aip.baidubce.com</span><br><span class="line">Content-Type: application/x-www-form-urlencoded; charset=utf<span class="number">-8</span></span><br><span class="line"></span><br><span class="line">imge=【图片数据】-------【图片数据】</span><br></pre></td></tr></table></figure>


<h3 id="multipart-form-data"><a href="#multipart-form-data" class="headerlink" title="multipart/form-data"></a>multipart/form-data</h3><p>此种方法并不符合百度的要求，只是拓展：<br><code>multipart/form-data</code>也就是在header里面首先声明用于数据分界的boundary然后在boundary和boundary之间插入数据</p>
<ul>
<li>自定义的<code>boundary</code>在body中使用的时候需要包含<code>--</code></li>
<li><code>boundary</code>需要在前面和末尾都需要放上<code>--</code></li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line">Header</span><br><span class="line">Content-Type: multipart&#x2F;form-data; charset&#x3D;utf-8; boundary&#x3D;[boundaryValues]</span><br><span class="line"></span><br><span class="line">Body</span><br><span class="line">--[boundaryValues]</span><br><span class="line">Content-Disposition: form-data; name&#x3D;&quot;signature&quot;</span><br><span class="line"></span><br><span class="line">[Values]</span><br><span class="line">--[boundaryValues]</span><br><span class="line"></span><br><span class="line">[Values]</span><br><span class="line">--[boundaryValues]--</span><br></pre></td></tr></table></figure>

<h4 id="代码实现"><a href="#代码实现" class="headerlink" title="代码实现"></a>代码实现</h4><figure class="highlight objectivec"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">NSString</span> *boundary = <span class="string">@&quot;0xKhTmLbOuNdArY-9A384603-C818-4456-8523-456FF155ECC1&quot;</span>;</span><br><span class="line">    <span class="built_in">NSMutableData</span> *body = [<span class="built_in">NSMutableData</span> data];</span><br><span class="line">[body appendData:[[<span class="built_in">NSString</span> stringWithFormat:<span class="string">@&quot;--%@\r\n&quot;</span>, boundary] dataUsingEncoding:<span class="built_in">NSUTF8StringEncoding</span>]];</span><br><span class="line">[body appendData:[<span class="string">@&quot;Content-Disposition: form-data; name=\&quot;signature\&quot;\r\n\r\n&quot;</span> dataUsingEncoding:<span class="built_in">NSUTF8StringEncoding</span>]];</span><br><span class="line">[body appendData:[[<span class="built_in">NSString</span> stringWithFormat:<span class="string">@&quot;%@\r\n&quot;</span>, imageDate.stringByURLEncode] dataUsingEncoding:<span class="built_in">NSUTF8StringEncoding</span>]];</span><br><span class="line">[body appendData:[[<span class="built_in">NSString</span> stringWithFormat:<span class="string">@&quot;--%@--\r\n&quot;</span>, boundary] dataUsingEncoding:<span class="built_in">NSUTF8StringEncoding</span>]];</span><br><span class="line"></span><br><span class="line"><span class="built_in">NSURLSessionConfiguration</span> *sessionConfiguration = [<span class="built_in">NSURLSessionConfiguration</span> defaultSessionConfiguration];</span><br><span class="line"><span class="built_in">NSURLSession</span> *session = [<span class="built_in">NSURLSession</span> sharedSession];</span><br><span class="line"></span><br><span class="line"><span class="built_in">NSURL</span> *url = [<span class="built_in">NSURL</span> URLWithString:<span class="string">@&quot;Https://aip.baidubce.com/rest/2.0/image-classify/v2/advanced_general?access_token=token];</span></span><br><span class="line"><span class="string">NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];</span></span><br><span class="line"><span class="string">request.HTTPMethod = @&quot;</span>POST<span class="string">&quot;;</span></span><br><span class="line"><span class="string">request.HTTPBody = body;</span></span><br><span class="line"><span class="string">    </span></span><br><span class="line"><span class="string">[request addValue:[NSString stringWithFormat:@&quot;</span>multipart/form-data; charset=utf<span class="number">-8</span><span class="string">&quot;] forHTTPHeaderField:@&quot;</span>Content-Type<span class="string">&quot;];</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">NSURLSessionDataTask *uploadTask = [session dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) &#123;</span></span><br><span class="line"><span class="string">        //百度返回结果</span></span><br><span class="line"><span class="string">&#125;];</span></span><br><span class="line"><span class="string">[uploadTask resume];</span></span><br></pre></td></tr></table></figure>

<h4 id="最终格式-1"><a href="#最终格式-1" class="headerlink" title="最终格式"></a>最终格式</h4><figure class="highlight objectivec"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line">POST /BusinessUser/Api/editHeadImg HTTP/<span class="number">1.1</span></span><br><span class="line">Host: api.btmart.cn</span><br><span class="line">Content-Type: multipart/form-data; charset=utf<span class="number">-8</span>; boundary=<span class="number">0</span>xKhTmLbOuNdArY<span class="number">-9</span>A384603-C818<span class="number">-4456</span><span class="number">-8523</span><span class="number">-456</span>FF155ECC1</span><br><span class="line"></span><br><span class="line">-<span class="number">-0</span>xKhTmLbOuNdArY<span class="number">-9</span>A384603-C818<span class="number">-4456</span><span class="number">-8523</span><span class="number">-456</span>FF155ECC1</span><br><span class="line">Content-Disposition: form-data; name=<span class="string">&quot;signature&quot;</span>;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">【图片数据】-------【图片数据】</span><br><span class="line">-<span class="number">-0</span>xKhTmLbOuNdArY<span class="number">-9</span>A384603-C818<span class="number">-4456</span><span class="number">-8523</span><span class="number">-456</span>FF155ECC1--</span><br></pre></td></tr></table></figure>

<h2 id="References"><a href="#References" class="headerlink" title="References"></a>References</h2><p><a target="_blank" rel="noopener" href="https://ai.baidu.com/docs#/ImageClassify-API/b334b55e">百度文档位置</a><br><a target="_blank" rel="noopener" href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/POST">application/x-www-form-urlencoded:类型的数据应该怎么拼接</a></p>

    </div>

    
    
    
        

  <div class="followme">
    <p>Welcome to my other publishing channels</p>

    <div class="social-list">

        <div class="social-item">
          <a target="_blank" class="social-link" href="/atom.xml">
            <span class="icon">
              <i class="fa fa-rss"></i>
            </span>

            <span class="label">RSS</span>
          </a>
        </div>
    </div>
  </div>


      <footer class="post-footer">

        


        
    <div class="post-nav">
      <div class="post-nav-item">
    <a href="/2019/06/17/POSIX/BSD%20socket/" rel="prev" title="BSD socket">
      <i class="fa fa-chevron-left"></i> BSD socket
    </a></div>
      <div class="post-nav-item"></div>
    </div>
      </footer>
    
  </article>
  
  
  



          </div>
          

<script>
  window.addEventListener('tabs:register', () => {
    let { activeClass } = CONFIG.comments;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      let commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          Table of Contents
        </li>
        <li class="sidebar-nav-overview">
          Overview
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
          <div class="post-toc motion-element"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#%E7%99%BE%E5%BA%A6%E5%9B%BE%E7%89%87%E8%AF%B7%E6%B1%82"><span class="nav-number">1.</span> <span class="nav-text">百度图片请求</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#HTTP-body%E7%9A%84%E6%95%B0%E6%8D%AE%E7%9A%84%E6%A0%BC%E5%BC%8F"><span class="nav-number">2.</span> <span class="nav-text">HTTP body的数据的格式</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#application-x-www-form-urlencoded"><span class="nav-number">2.1.</span> <span class="nav-text">application&#x2F;x-www-form-urlencoded</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#%E4%BB%A3%E7%A0%81"><span class="nav-number">2.1.1.</span> <span class="nav-text">代码</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#%E6%9C%80%E7%BB%88%E6%A0%BC%E5%BC%8F"><span class="nav-number">2.1.2.</span> <span class="nav-text">最终格式</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#multipart-form-data"><span class="nav-number">2.2.</span> <span class="nav-text">multipart&#x2F;form-data</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#%E4%BB%A3%E7%A0%81%E5%AE%9E%E7%8E%B0"><span class="nav-number">2.2.1.</span> <span class="nav-text">代码实现</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#%E6%9C%80%E7%BB%88%E6%A0%BC%E5%BC%8F-1"><span class="nav-number">2.2.2.</span> <span class="nav-text">最终格式</span></a></li></ol></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#References"><span class="nav-number">3.</span> <span class="nav-text">References</span></a></li></ol></div>
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
  <p class="site-author-name" itemprop="name">HR</p>
  <div class="site-description" itemprop="description">Swimming 🏊 in the sea🌊of code!</div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/archives/">
        
          <span class="site-state-item-count">38</span>
          <span class="site-state-item-name">posts</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
            <a href="/categories/">
          
        <span class="site-state-item-count">9</span>
        <span class="site-state-item-name">categories</span></a>
      </div>
      <div class="site-state-item site-state-tags">
            <a href="/tags/">
          
        <span class="site-state-item-count">6</span>
        <span class="site-state-item-name">tags</span></a>
      </div>
  </nav>
</div>
  <div class="links-of-author motion-element">
      <span class="links-of-author-item">
        <a href="mailto:caohr@outlook.com" title="E-Mail → mailto:caohr@outlook.com" rel="noopener" target="_blank"><i class="fa fa-envelope fa-fw"></i>E-Mail</a>
      </span>
  </div>



      </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

        

<div class="copyright">
  
  &copy; 
  <span itemprop="copyrightYear">2021</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">HR</span>
</div>
  <div class="powered-by">Powered by <a href="https://hexo.io/" class="theme-link" rel="noopener" target="_blank">Hexo</a> & <a href="https://pisces.theme-next.org/" class="theme-link" rel="noopener" target="_blank">NexT.Pisces</a>
  </div>

        








      </div>
    </footer>
  </div>

  
  <script src="/lib/anime.min.js"></script>
  <script src="/lib/velocity/velocity.min.js"></script>
  <script src="/lib/velocity/velocity.ui.min.js"></script>

<script src="/js/utils.js"></script>

<script src="/js/motion.js"></script>


<script src="/js/schemes/pisces.js"></script>


<script src="/js/next-boot.js"></script>




  















  

  

</body>
</html>
